package com.lm.activiti.boot.datatype;

import com.alibaba.fastjson.JSON;
import com.beust.jcommander.internal.Sets;
import com.google.common.collect.Lists;
import com.lm.activiti.boot.dto.Animal;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author lm_jcf
 * @date 2020/3/27 15:44
 */
public class ListDemo {

    @Test
    public void subList(){

        List<Integer> list = Lists.newLinkedList();
        list.add(2);
        list.add(3);
        list.add(1);
        list.add(1);
        list.add(1);

        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(2);

//        System.out.println(list);

        list.stream().filter(e -> e != 2);

        System.out.println(list);


        List<Integer> list1 = list.subList(list.size() - 4, list.size());
//        System.out.println(list1);



    }


    @Test
    public void remove(){
        Set<Integer> set = Sets.newHashSet();
        set.add(1);
        set.add(12);
        set.add(13);
        set.add(14);

        Set<Integer> set1 = Sets.newHashSet();
        set1.add(12);

        set.removeAll(set1);
        System.out.println(set);
    }

    @Test
    public void initialField(){

        Animal animal = new Animal("张三", 170);

        System.out.println(JSON.toJSONString(animal));

    }

    @Test
    public void printBinary() {
        int i = 2 | 8;
        System.out.println(Integer.toBinaryString(2));
        System.out.println(Integer.toBinaryString(8));
        System.out.println(Integer.toBinaryString(i));

    }


    @Test
    public void test(){
        List<Date> dateList = Lists.newArrayList();
        dateList.add(new Date());

        List<String> collect = dateList.stream().map(attenTime -> "--").collect(Collectors.toList());

        System.out.println(collect);
    }
}
